function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { core, getRegisterCpt, getRegisterCptWithProps, registerCpts, setGlobalVar } from '@newgrand/iup-core';
import { useEffect } from 'react';
import { CommonUtil } from "./common";
export * from '@newgrand/iup-core';
export var iup = _objectSpread(_objectSpread(_objectSpread({}, core), CommonUtil), {}, {
  registerExternal: function registerExternal(obj) {
    core.registerExternal(obj, false);
  }
});
export function registerComponent(Components, options) {
  registerCpts(Components, _objectSpread(_objectSpread({}, options), {}, {
    platform: 'pc'
  }));
}
export function getRegisterComponent() {
  var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  var candidate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  return getRegisterCpt(type, 'pc', candidate);
}
export function getRegisterComponentWithProps() {
  var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  var candidate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  return getRegisterCptWithProps(type, 'pc', candidate);
}

/**
 * 回刷列表hook
 * @param effect 回刷列表的副作用函数
 * @param busType 业务类型
 */
export function useRefreshList(effect, busType) {
  useEffect(function () {
    return CommonUtil.onRefreshList(busType, effect);
  }, []);
}
export function getGlobalContainer() {
  var _iup$external$getQian, _iup$external;
  var name = (_iup$external$getQian = (_iup$external = iup.external).getQianKun) === null || _iup$external$getQian === void 0 ? void 0 : _iup$external$getQian.call(_iup$external).name;
  return name ? document.body.querySelector("div[data-qiankun=\"".concat(name, "\"]")) || document.body : document.body;
}
export function getFileCenterApiUrl(relativeUrl) {
  var _iup$getUser = iup.getUser(),
    fileUrl = _iup$getUser.fileUrl;
  return {
    absUrl: fileUrl ? true : false,
    url: fileUrl ? "".concat(fileUrl).concat(relativeUrl) : relativeUrl
  };
}
var isDev = process.env.NODE_ENV === 'development';
export function getIUPFilePreviewUrl(fileId) {
  var _iup$getUser2 = iup.getUser(),
    accessToken = _iup$getUser2.accessToken;
  var _getFileCenterApiUrl = getFileCenterApiUrl("/iup-file/doc/file/preview?fileId=".concat(fileId, "&User-Token=").concat(accessToken)),
    url = _getFileCenterApiUrl.url,
    absUrl = _getFileCenterApiUrl.absUrl;
  var nextUrl = absUrl ? url : "".concat(isDev ? '/proxy' : location.origin).concat(url);
  return {
    url: nextUrl,
    absUrl: absUrl
  };
}
/**
 * 暴露全局变量api
 */
setGlobalVar('$iup', iup);